//
//  ButtonViewController.m
//  LastTemp
//
//  Created by dllo on 15/4/21.
//  Copyright (c) 2015年 dllo. All rights reserved.
//

#import "ButtonViewController.h"
#import "HomePageViewController.h"
#import "musicViewController.h"
#import "MyViewController.h"
#import "SearchViewController.h"
@interface ButtonViewController ()
@property(nonatomic,retain)UIButton *homeButton;
@property(nonatomic,retain)UIButton *myButton;
@property(nonatomic,retain)UIButton *searchButton;
@property(nonatomic,retain)UIButton *musicButton;
@end

@implementation ButtonViewController

- (void)viewDidLoad {
    [super viewDidLoad];
    // Do any additional setup after loading the view.
    self.homeButton = [UIButton buttonWithType:UIButtonTypeSystem];
    [self addButton:self.homeButton x:0 name:@"首页" tag:1001];
    self.myButton = [UIButton buttonWithType:UIButtonTypeSystem];
    [self addButton:self.myButton x:self.view.frame.size.width/4 name:@"我的" tag:1002];
    self.searchButton = [UIButton buttonWithType:UIButtonTypeSystem];
    [self addButton:self.searchButton x:self.view.frame.size.width/4*2 name:@"搜索" tag:1003];
    self.musicButton = [UIButton buttonWithType:UIButtonTypeSystem];
    [self addButton:self.musicButton x:self.view.frame.size.width/4*3 name:@"音乐库" tag:1004];
    self.navigationController.navigationBarHidden = YES;
    
}

- (void)addButton:(UIButton *)button x:(NSInteger)x name:(NSString *)name tag:(NSInteger)tag
{
    button.frame = CGRectMake(x, 30, self.view.frame.size.width/4+1, 50);
    [self.view addSubview:button];
    //    button.layer.cornerRadius = 5;
    [button setTitle:name forState:UIControlStateNormal];
    button.backgroundColor = [UIColor whiteColor];
    button.tag = tag;
    [button addTarget:self action:@selector(click:) forControlEvents:UIControlEventTouchUpInside];
    button.backgroundColor = [UIColor colorWithRed:34/255.0 green:34/255.0 blue:37/255.0 alpha:1];
    

}

- (void)click:(UIButton *)button
{
    if (button.tag == 1001) {
        HomePageViewController *home = [[HomePageViewController alloc] init];
        [self.navigationController pushViewController:home animated:YES];
        home.colorNum = 1;
       
    } else if (button.tag == 1002) {
        MyViewController *my = [[MyViewController alloc] init];
        [self.navigationController pushViewController:my animated:YES];
        my.colorNum = 1;
        
    } else if (button.tag == 1003) {
        SearchViewController *se = [[SearchViewController alloc] init];
        [self.navigationController pushViewController:se animated:YES];
        se.colorNum = 1;
       
    } else if (button.tag == 1004) {
        musicViewController *music = [[musicViewController alloc] init];
        [self.navigationController pushViewController:music animated:YES];
        music.colorNum = 1;
       
    }
}

- (void)didReceiveMemoryWarning {
    [super didReceiveMemoryWarning];
    // Dispose of any resources that can be recreated.
}

/*
#pragma mark - Navigation

// In a storyboard-based application, you will often want to do a little preparation before navigation
- (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender {
    // Get the new view controller using [segue destinationViewController].
    // Pass the selected object to the new view controller.
}
*/

@end
